// 例子7

{
    let [a, b, c] = [1, 2, 3]; // 相当于 let a = 1; let b = 2; let c = 3;
    console.log(a, b, c); // 1 2 3
}

{
    let [foo, [
        [bar], baz
    ]] = [1, [
        [2], 3
    ]];
    console.log(foo, bar, baz); // 1 2 3
}

{
    let [, , third] = ['foo', 'bar', 'baz'];
    console.log(third); // "baz"
}

console.log('----------------------------------');

{
    let [x, , y] = [1, 2, 3];
    console.log(x, y); // 1 3
}

console.log('----------------------------------');

{
    let [head, ...tail] = [1, 2, 3, 4];
    console.log(head, tail); // 1 [2, 3, 4]
}

console.log('----------------------------------');

{
    let [x, y, ...z] = ['a'];
    console.log(x, y, z); // "a" undefined [],其中y匹配失败，为undefined
}

console.log('----------------------------------');

{
    let [x, y] = [1, 2, 3]; // 不完全解构
    console.log(x, y); // 1 2
}